package com.haikesi.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName DocumentationConfig
 * @Author HandsomeBugs
 * @Date 2019/4/24 16:13
 * @Version 1.0
 **/

@Component
@Primary
public class DocumentationConfig implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
        List resources = new ArrayList<>();
        resources.add(swaggerResource("海克斯平台接口", "/v2/api-docs", "1.0"));
        resources.add(swaggerResource("会员管理", "/user/v2/api-docs", "1.0"));
        resources.add(swaggerResource("设备管理", "/device/v2/api-docs", "1.0"));
        resources.add(swaggerResource("日志管理", "/log/v2/api-docs", "1.0"));
        return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }

//    @Component
//    @Primary
//    class DocumentationConfig implements SwaggerResourcesProvider {
//
//        @Override
//        public List<SwaggerResource> get() {
//            List resources = new ArrayList();
//            resources.add(swaggerResource("用户相关Api","/user/v2/api-docs","2.0"));
//            resources.add(swaggerResource("设备相关Api","/device/v2/api-docs","2.0"));
//            return resources;
//        }
//
//        private SwaggerResource swaggerResource(String name, String location, String version) {
//            SwaggerResource swaggerResource = new SwaggerResource();
//            swaggerResource.setName(name);
//            swaggerResource.setLocation(location);
//            swaggerResource.setSwaggerVersion(version);
//            return swaggerResource;
//        }
//    }
}
